﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AteneoLibriBusinessLogic.Entities;

namespace AteneoLibriBusinessLogic.TOA
{
    public class BookAssembler
    {

        public static Book Assembler(AteneoLibriEntityFramework.Book item)
        {
            Book b = new Book();

            b.IdBook = item.IdBook;
            b.Title = item.Title;
            b.Author = item.Author;
            b.BookStatusId = item.BookStatusId;            
            b.Edition = item.Edition;
            b.Note = item.Note;
            b.ISBN = item.ISBN;
            b.SellingPrice = item.SellingPrice;
            b.CoverImage = item.CoverImage;
            b.PublishingHouse = item.PublishingHouse;
            b.UniversityId = item.UniversityId;
            b.FacultyId = item.FacultyId;
            b.InsertDate = item.InsertDate;
            b.UserId = item.UserId;
            // manca QRCode
            b.UserName = item.User.Username;
            
            b.IsDeleted = item.IsDeleted;

            return b;
        }

        public static AteneoLibriEntityFramework.Book DeAssembler(Book item)
        {
            AteneoLibriEntityFramework.Book b = new AteneoLibriEntityFramework.Book();

            b.IdBook = item.IdBook;
            b.Title = item.Title;
            b.Author = item.Author;
            b.BookStatusId = item.BookStatusId;            
            b.Edition = item.Edition;
            b.Note = item.Note;
            b.ISBN = item.ISBN;
            b.SellingPrice = item.SellingPrice;
            b.CoverImage = item.CoverImage;
            b.PublishingHouse = item.PublishingHouse;
            b.UniversityId = item.UniversityId;
            b.FacultyId = item.FacultyId;
            b.InsertDate = item.InsertDate;
            b.UserId = item.UserId;

            b.IsDeleted = item.IsDeleted;
            // manca QRCode            

            return b;
        }

        public static void WriteToEntity(AteneoLibriEntityFramework.Book entity, Book item)
        {
            entity.IdBook = item.IdBook;
            entity.Title = item.Title;
            entity.Author = item.Author;
            entity.BookStatusId = item.BookStatusId;
            entity.Edition = item.Edition;
            entity.Note = item.Note;
            entity.ISBN = item.ISBN;
            entity.SellingPrice = item.SellingPrice;
            entity.CoverImage = item.CoverImage;
            entity.PublishingHouse = item.PublishingHouse;
            entity.UniversityId = item.UniversityId;
            entity.FacultyId = item.FacultyId;
            entity.UserId = item.UserId;

            entity.IsDeleted = item.IsDeleted;
        }

    }
}
